﻿/// <reference path="RequestHandler.js" />
/// <reference path="../HttpRequest.js" />
/// <reference path="../../utilities/FXDom.js" />
/// <reference path="../../utilities/Markup.js" />
///--------------------------------------------------------------------
/// <file name="SignGuestbookHandler.js">
///   Adds markup buttons to the sign guestbook page.
/// </file>
///--------------------------------------------------------------------

NAMFox.ns(function() { with (NAMFox) {

this.SignGuestbookHandler = function() {
};

SignGuestbookHandler.prototype = new RequestHandler();
SignGuestbookHandler.prototype.name = "SignGuestbookHandler";

SignGuestbookHandler.prototype.handleRequestCore = function(request, _$) {
    /// <summary>Handles a request.</summary>
    /// <param name="request" type="HttpRequest">
    ///   The HTTP request which encapsulates the
    ///   document and route data for this request.
    /// </param>

    var textArea = _$("textarea[name=gb_msgbody]");

    request.htmlDocument.__namfox__.textArea = textArea;

    var notice = _$("span").get(1).innerHTML;
    $.verbose("CHECK: " + notice);
    if (
        textArea.val().length === 0 &&
        notice !== "Preview" &&
        notice !== "Error Submitting"
    ) {
        textArea.val($.messages.getDefaultMessage().text);
    }

    textArea.after(
        '<div id="namfox-guestbook-markup"></div>'
    ).find(
        "#namfox-guestbook-markup"
    ).append(
        Markup.create(
            textArea,
            MarkupLocation.SignGuestbook,
            Markup.bold,
            Markup.italics,
            Markup.underline,
            Markup.quote,
            Markup.linkName,
            Markup.superscript,
            Markup.subscript
        )
    );
};

}});